package com.yanqu.road.utils;

import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;

import java.lang.reflect.Type;
import java.math.BigInteger;

// 自定义反序列化器
public class BigIntegerDeserializer implements ObjectDeserializer {
    @Override
    public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        Object value = parser.parseObject(Object.class);
        if (value instanceof String) {
            return (T) new BigInteger((String) value);
        } else {
            return (T) new BigInteger(value.toString());
        }
    }

    @Override
    public int getFastMatchToken() {
        return 0;
    }
}
